package com.sunelec.service.Imp;

import com.sunelec.mapper.PowerMapper;
import com.sunelec.mapper.ReportMapper;
import com.sunelec.pojo.Collector;
import com.sunelec.pojo.Inverter;
import com.sunelec.pojo.Power;
import com.sunelec.pojo.stationRunTableExample3;
import com.sunelec.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 吴遵明
 * @Description: 用于ReportCenter所有功能
 * @Date: Create in 2018/05/08
 * @Modified By:
 */
@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private ReportMapper reportMapper;

    @Autowired
    private PowerMapper powerMapper;

    /**
     * 根据user3查询电站
     * @param level3user
     * @return
     */
    public List<Power> selectPowerWithUser3(String level3user) {
        return reportMapper.selectPowerWithUser3(level3user);
    }

    /**
     * 根据user2查询电站
     * @param
     * @return
     */
    public List<Power> selectPowerWithUser1() {
        return reportMapper.selectPowerWithUser1();
    }

    /**
     * 根据user2查询电站
     * @param level2user
     * @return
     */
    public List<Power> selectPowerWithUser2(String level2user) {
        return reportMapper.selectPowerWithUser2(level2user);
    }

    /**
     * 根据power_id查询所有的collector
     * @param li
     * @return
     */
    @Override
    public List<Collector> selectCollectorWithPowerid(List li) {
        return reportMapper.selectCollectorWithPowerid(li);
    }

    /**
     * 根据power_id查询所有的collector
     * @param collectorid
     * @return
     */
    @Override
    public String selectPowernameWithCollectorid(String collectorid) {
        return reportMapper.selectPowernameWithCollectorid(collectorid);
    }

    /**
     * 根据date天数，leveluser,type查询所有stationRunTablePOJO
     * @param date,leveluser,type
     * @return
     */
    /*public List<stationRunTablePOJO> selectStationRunByDate(String date, String leveluser, int type) {
        return reportMapper.selectStationRunByDate(date, leveluser, type);
    }*/

    /**
     * 根据date天数，power_id来查询所有Inverter
     * @param date,power_id
     * @return
     */
     public List<Inverter> selectInverterByDate(String date, String power_id) {
        return reportMapper.selectInverterByDate(date, power_id);
    }

    /**
     * 根据power_name,type,leveluser查询power_id;
     * @param power_name,leveluser,type
     * @return
     */
    public Power selectPowerId(String power_name, String leveluser, int type) {
         return reportMapper.selectPowerId(power_name, leveluser, type);
    }

    /**
     * 根据update_date,power_id查询，1.该update_date之前，2.每天最大电量，3.不同sn
     * @param power_id, update_date
     * @return
     */
    public List<stationRunTableExample3> selectElecByPowerId(String power_id, String update_date) {
        return reportMapper.selectElecByPowerId(power_id, update_date);
    }

    /**
     * 根据update_dateMin, update_dateMax, power_id查询，1.update_dateMin, update_dateMax之间，2.每天最大电量，3.不同sn
     * @param power_id, update_dateMin, update_dateMax
     * @return
     */
    public List<stationRunTableExample3> selectElecByPowerId2(String power_id, String update_dateMin, String update_dateMax) {
        return reportMapper.selectElecByPowerId2(power_id, update_dateMin, update_dateMax);
    }

    /**
     * 根据power_id查询power;
     * @param power_id
     * @return
     */
    public Power selectPowerById(String power_id) {
        return powerMapper.selectByPrimaryKey(power_id);
    }

    /**
     * 根据collector_sn, date, time，查询该sn下的date之前总电量，精确到time
     * @param collector_sn,date
     * @return
     */
    public Float selectElectricitySUMByDate(String collector_sn, String date) {
        return reportMapper.selectElectricitySUMByDate(collector_sn, date);
    }

    /**
     * 根据collector_sn, date, time，查询该sn下的date当天总电量，精确到time
     * @param collector_sn,date,time
     * @return
     */
    public Float selectElectricityDAYByDate(String collector_sn, String date, String time) {
        return reportMapper.selectElectricityDAYByDate(collector_sn, date, time);
    }
}
